/*
 *  AdvancedMouseEventArgs.cs
 *  
 *  Provides data for the AdvancedMouseEventListener class.
 *  
 *  Copyright (c) 2009, Richard Bao Labs.
 *  
 *  The contents of this file are subject to the Mozilla Public License
 *  Version 1.1 (the "License"); you may not use this file except in
 *  compliance with the License. You may obtain a copy of the License at
 *  
 *  http://www.mozilla.org/MPL/
 *  
 *  Software distributed under the License is distributed on an "AS IS"
 *  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 *  the License for the specific language governing rights and limitations
 *  under the License.
 *  
 *  The Original Code is OpenPainter.
 *  
 *  The Initial Developer of the Original Code is OpenPainter.org.
 *  All Rights Reserved.
 */

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace RichControlLibrary
{
    /// <summary>
    /// Provides data for the <see cref="AdvancedMouseEventsMonitor"/> class.
    /// </summary>
    public class AdvancedMouseEventArgs : MouseEventArgs
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AdvancedMouseEventArgs"/> class.
        /// </summary>
        /// <param name="button">One of the <see cref="System.Windows.Forms.MouseButtons"/> values 
        /// indicating which mouse button was pressed.</param>
        /// <param name="clicks">The number of times a mouse button was pressed.</param>
        /// <param name="x">The x-coordinate of a mouse click, in pixels.</param>
        /// <param name="y">The y-coordinate of a mouse click, in pixels.</param>
        /// <param name="delta">A signed count of the number of detents the wheel has rotated.</param>
        /// <param name="isDragging">A boolean value that indicates whether user is dragging.</param>
        /// <param name="draggingAnchor">A <see cref="System.Drawing.Point"/> that is the starting point of dragging.</param>
        /// <param name="lastMovedVector">A <see cref="System.Drawing.Size"/> that indicates the last moved vector.</param>
        public AdvancedMouseEventArgs(
            MouseButtons button,
            int clicks,
            int x,
            int y,
            int delta,
            bool isDragging,
            Point draggingAnchor,
            Size lastMovedVector)
            : base(button, clicks, x, y, delta)
        {
            this._isDragging = isDragging;
            this._draggingAnchor = draggingAnchor;
            this._lastMovedVector = lastMovedVector;
        }

        private bool _isDragging = false;
        /// <summary>
        /// Gets a boolean value that indicates whether the user is dragging on the target.
        /// </summary>
        public bool IsDragging
        {
            get { return _isDragging; }
        }

        private Point _draggingAnchor = new Point();
        /// <summary>
        /// Gets the starting point of the dragging action. The point is based on the screen.
        /// </summary>
        public Point DraggingAnchor
        {
            get { return _draggingAnchor; }
        }

        private Size _lastMovedVector = new Size();
        /// <summary>
        /// Gets the vector of the last move. The vector is based on the screen.
        /// </summary>
        public Size LastMovedVector
        {
            get { return _lastMovedVector; }
        }

        /// <summary>
        /// Gets a <see cref="System.Drawing.Size"/> that indicates the dragged size.
        /// </summary>
        public Size DraggedSize
        {
            get
            {
                return new Size(
                    this.Location.X - this._draggingAnchor.X,
                    this.Location.Y - this._draggingAnchor.Y);
            }
        }

        /// <summary>
        /// Gets a <see cref="System.Drawing.Rectangle"/> that indicates the dragged area.
        /// </summary>
        public Rectangle DraggedBounds
        {
            get
            {
                int x1 = Location.X;
                int x2 = this._draggingAnchor.X;
                int y1 = Location.Y;
                int y2 = this._draggingAnchor.Y;

                return new Rectangle(
                    Math.Min(x1, x2),
                    Math.Min(y1, y2),
                    Math.Abs(x2 - x1),
                    Math.Abs(y2 - y1));
            }
        }
    }
}
